from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from Po.Base import Base
import time

class Page(Base):

    text_loc1=(By.XPATH,'//*[@id="s-top-left"]/a[1]')
    ssk_loc=(By.XPATH,'//*[@id="chat-textarea"]')
    ss_loc=(By.XPATH,'//*[@id="chat-submit-button"]')
    dir_loc=(By.XPATH,'//*[@id="page"]/div/a[1]/span')
    text_loc2=(By.XPATH,'//*[@id="u"]/a[1]')

    def text1(self):
        return self.text(self.text_loc1)
    def ssk(self):
        self.send_keys(self.ssk_loc,'我喜欢软件测试')
    def ss(self):
        self.click(self.ss_loc)

    def dir(self):
        self.click(self.dir_loc)

    def text2(self):
        return self.text(self.text_loc2)

    def baidu(self):
        self.open_url('https://www.baidu.com/')
        a=self.text1()
        assert a=='新闻'
        print(f'页面是{a},已打开百度')
        self.ssk()
        self.ss()
        self.dir()
        time.sleep(3)
        print("包含关键词‘软件测试’")
        # time.sleep(3)
        # a=self.text1()
        # assert a=='我喜欢软件测试'
        # print(a)